package com.itheima.demo003;

public class test23 {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        //容量：最多装多少（全世界的$）
        //长度：实际装多少（我的钱包￥）

        //刚开始创建，默认容量为16
        System.out.println(sb.capacity());//容量16
        System.out.println(sb.length());//长度0

        //①添加abc
        sb.append("abc");
        System.out.println(sb.capacity());//16
        System.out.println(sb.length());//3

        //②添加a~z    长度超过16，扩容：老容量*2+2=34
        sb1.append("abcdefghijklmnopqrstuvwxyz");
        System.out.println(sb1.capacity());//34
        System.out.println(sb1.length());//26

        //③添加a~z和0~9    长度超过34，则以实际容量为准
        sb2.append("abcdefghijklmnopqrstuvwxyz0123456789");
        System.out.println(sb2.capacity());//36
        System.out.println(sb2.length());//36
    }
}
